<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- 
 * pdml2html.xsl
 *
 * This XSLT will convert a PDML file, saved by Wireshark, into
 *    HTML. The HTML page should look like Wireshark. - prototype
 *
 *
 * LICENSE: 
 * This file is part of EasyShark.
 *
 *   Easypcap is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   EasyShark is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author     Balazs Barcsik <balazs.barcsik@gmail.com>
 * @license    http://www.gnu.org/licenses/gpl.txt 
 * @version    2013-08-24 
 -->
<!-- This XSLT will convert a PDML file, saved by Wireshark, into
     HTML. The HTML page should look like Wireshark. For questions contact
     Dirk Jagdmann (doj@cubic.org).
     Version: 2010-06-09 -->

<!-- set parameters of the HTML output -->
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" indent="yes"/>

<xsl:variable name="vUpper" select=
 "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
 <xsl:param name="window"/>
 
<!-- this matches the "field" tag -->

<xsl:template  match="field">
<xsl:param name="type"/>

<xsl:choose>
<xsl:when test="$type='compair'">
<xsl:choose>
    <xsl:when test="string-length(@showname)>0">
     <xsl:value-of select="@showname"/>
    </xsl:when>
    <xsl:otherwise> 
    <xsl:value-of select="@show"/>
    </xsl:otherwise>
  </xsl:choose>
   <xsl:apply-templates> <!-- we expect to match "field" tags -->
         <xsl:with-param name="type">compair</xsl:with-param>
         </xsl:apply-templates>
</xsl:when>

<xsl:when test="$type='octet'">
<xsl:choose>
<xsl:when test="@name='ip.frag_offset'">
    <!-- pos: <xsl:value-of select="@pos"/> size: <xsl:value-of select="@size"/> value: <xsl:value-of select="@value"/>-->00
     </xsl:when>
     <xsl:otherwise>
<xsl:choose>
<xsl:when test="string-length(@name)>0 and @name!='tcp.pdu.size'">
<xsl:choose>
<xsl:when test="string-length(@value)>0">
<xsl:choose>
<xsl:when test="string-length(@hide)=0">
<xsl:choose>
<xsl:when test="string-length(preceding-sibling::field[1]/@show)>0">
<xsl:choose>
<xsl:when test="preceding-sibling::field[1]/@pos!=@pos">
<xsl:choose>
<xsl:when test="string-length(@unmaskedvalue)>0">
     <!-- pos: <xsl:value-of select="@pos"/> size: <xsl:value-of select="@size"/> unmaskedvalue: --><xsl:value-of select="@unmaskedvalue"/>
     </xsl:when>
     <xsl:otherwise> 
    <!-- pos: <xsl:value-of select="@pos"/> size: <xsl:value-of select="@size"/> value: --><xsl:value-of select="@value"/>
    </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    </xsl:choose>
    </xsl:when>
    <xsl:otherwise> 
    <xsl:choose>
<xsl:when test="string-length(@unmaskedvalue)>0">
    <!-- pos: <xsl:value-of select="@pos"/> size: <xsl:value-of select="@size"/> unmaskedvalue: --><xsl:value-of select="@unmaskedvalue"/>
    </xsl:when>
    <xsl:otherwise> 
    <!-- pos: <xsl:value-of select="@pos"/> size: <xsl:value-of select="@size"/> value: --><xsl:value-of select="@value"/>
    </xsl:otherwise>
    </xsl:choose>
    
    </xsl:otherwise>
  </xsl:choose>
  </xsl:when>
  </xsl:choose>
  </xsl:when>
  </xsl:choose>
  </xsl:when>
  </xsl:choose>
</xsl:otherwise>
</xsl:choose>  

<xsl:choose>
<xsl:when test="@name='tcp.checksum'">
    00 00
     </xsl:when>
</xsl:choose>
 
<xsl:choose>
<xsl:when test="@name='tcp.flags'">
    <xsl:value-of select="@value"/>
     </xsl:when>
</xsl:choose>
</xsl:when>


<xsl:otherwise>


<xsl:variable name="count" select="count(ancestor::*)" />

  <!-- indent with 3 non-breaking spaces -->
  <xsl:choose>
  <xsl:when test="@name='ip.src'">
  
  <script>
  this.src='<xsl:value-of select="@show" />';
  <!--  $('.diagram').append('<xsl:value-of select="@show" />-> ');-->
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
 
  <xsl:choose>
  <xsl:when test="@name='ip.dst'">
  <script>
   this.dst='<xsl:value-of select="@show" />';
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
  <xsl:choose>
  <xsl:when test="@name='diameter.cmd.code'">
  <script>
   this.msg=' <xsl:value-of select="@showname" />';
  $('#language').append(this.src+this.src_port + " -> "+this.dst+this.dst_port+" : "+this.msg+"\n");

  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
  <xsl:choose>
  <xsl:when test="@name='http.request.method'">
  <script>
   this.msg=' <xsl:value-of select="@show" />';
   
   $('#language').append(this.src+this.src_port + " -> "+this.dst+this.dst_port+" : "+this.msg+"\n");
   
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
  <xsl:choose>
  <xsl:when test="@name='data'">
  <script>
  
  var unknownid = "#<xsl:value-of select="$window" />unknown";
  <![CDATA[
   
   this.msg='unknown';
   var length = this.unknownArray.length;
   var found = false;
   var temp = new Array();
   temp[0] = this.src+this.src_port;
   temp[1] = this.dst+this.dst_port;
   
   
   for (var i = 0; i < length && !found; i++) {
     if((this.unknownArray[i][0] == temp[0] && this.unknownArray[i][1] == temp[1]) ||
         (this.unknownArray[i][0] == temp[1] && this.unknownArray[i][1] == temp[0])) {
       found = true;
     }
      // Do something with element i.
   }
   
   
   if(found) {
   } else {
     this.unknownArray[this.unknownArray.length] = [this.src+this.src_port,this.dst+this.dst_port];
     $(unknownid).append(this.unknownArray.length+".: "+this.unknownArray[this.unknownArray.length-1][0]+" - "+this.unknownArray[this.unknownArray.length-1][1]+"<br>");
   }
   
   
   $('#language').append(this.src+this.src_port + " -> "+this.dst+this.dst_port+" : "+this.msg+"\n");
   ]]>
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
  <xsl:choose>
  <xsl:when test="@name='tcp.srcport'">
  <script>
   this.src_port=' <xsl:value-of select="@show" />';
   
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
  <xsl:choose>
  <xsl:when test="@name='tcp.dstport'">
  <script>
  
   this.dst_port=' <xsl:value-of select="@show" />';
   <![CDATA[
   var temp = new Array();
   temp[0] = this.src+this.src_port;
   temp[1] = this.dst+this.dst_port;
   
   var length = this.connArray.length;
   var element = null;
   var found = false;
   for (var i = 0; i < length && !found; i++) {
     if((this.connArray[i][0] == temp[0] && this.connArray[i][1] == temp[1]) ||
         (this.connArray[i][0] == temp[1] && this.connArray[i][1] == temp[0])) {
       found = true;
     }
      // Do something with element i.
   }
   
   
   if(found) {
   } else {
     this.connArray[this.connArray.length] = [this.src+this.src_port,this.dst+this.dst_port];
   }
   
   ]]>
   
  </script>
  </xsl:when>
  <xsl:otherwise>
  </xsl:otherwise>
  </xsl:choose>
  
    <!--
  <xsl:choose>
    <xsl:when test="contains(@name, 'diameter') and string-length(@name) != string-length(translate(@name,$vUpper,''))">
     <xsl:value-of select="@showname" />
      <input type="text">
      <xsl:attribute name="id">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <xsl:attribute name="name">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <xsl:attribute name="value">
        <xsl:value-of select="@value" />
      </xsl:attribute>
      </input>
      
      <br/>
    </xsl:when>
    <xsl:otherwise>
    
    </xsl:otherwise>
  </xsl:choose>-->
  
  <!-- FIXME get unique id, instead of this -->
  <xsl:variable name="frame_num" select="ancestor::packet[1]/proto[@name='frame']/field[@name='frame.number']/@show"/>
  <xsl:variable name="frame_id"  select="concat($window,$frame_num)"/>
  <xsl:variable name="frame_c"   select="concat($frame_id,'c')"/>
  <xsl:variable name="protoId"  select="ancestor::proto[1]/@name"/> 
  <!-- FIXME get the position of the proto instead of the name
  <xsl:variable name="protoId"  select="count(ancestor::packet[1]/preceding-sibling::*[name()='proto'])"/>-->
  <xsl:variable name="msgId"  select="concat($frame_id,$protoId)"/>
  <xsl:variable name="level" select="count(ancestor::*)" />
  
  <xsl:variable name="field_level"  select="concat($msgId,$level)"/>
  
  <xsl:variable name="field_parent_num"  select="count(../preceding-sibling::*[name()='field'])"/>
  
  <xsl:variable name="field_num"  select="count(preceding-sibling::*[name()='field'])"/>
  
  <xsl:variable name="field_parent_id"  select="concat($field_level,$field_parent_num)"/>
 
  <xsl:variable name="field_id"  select="concat($field_parent_id,$field_num)"/>
  
  <xsl:choose>
  <xsl:when test="field">
  
 
  <div width="100%" id="parent_{$field_id}" onCLick="select_field('{$window}','parent_{$field_id}', 'span_octet_{$frame_c}','pos_{$field_id}', 'size_{$field_id}')">
  <span id="pos_{$field_id}" style="display:none"><xsl:value-of select="@pos"/></span>
  <span id="size_{$field_id}" style="display:none"><xsl:value-of select="@size"/></span>
  <a href="javascript:toggle_node('{$field_id}')">=></a>_<xsl:value-of select="@showname"/></div>
        
        <div width="100%" id="{$field_id}" style="display:none">
         <xsl:apply-templates select="field">
         <xsl:with-param name="type">detail</xsl:with-param>
         </xsl:apply-templates> 
        </div>
    
  
</xsl:when>
<xsl:otherwise>
<xsl:choose>
    <xsl:when test="string-length(@hide)=0">
 <xsl:choose>
    <xsl:when test="string-length(@showname)>0">
    <div width="100%" id="parent_{$field_id}" onCLick="select_field('{$window}','parent_{$field_id}', 'span_octet_{$frame_c}','pos_{$field_id}', 'size_{$field_id}')">
  <span id="pos_{$field_id}" style="display:none"><xsl:value-of select="@pos"/></span>
  <span id="size_{$field_id}" style="display:none"><xsl:value-of select="@size"/></span>
     <xsl:value-of select="@showname"/></div>
     
    </xsl:when>
    <xsl:otherwise> 
    <div width="100%" id="parent_{$field_id}" onCLick="select_field('{$window}','parent_{$field_id}', 'span_octet_{$frame_c}','pos_{$field_id}', 'size_{$field_id}')">
  <span id="pos_{$field_id}" style="display:none"><xsl:value-of select="@pos"/></span>
  <span id="size_{$field_id}" style="display:none"><xsl:value-of select="@size"/></span>
    <xsl:value-of select="@show"/></div>
     
    </xsl:otherwise>
  </xsl:choose>
  </xsl:when>
  </xsl:choose>
</xsl:otherwise>
  </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="proto">
<xsl:choose>
<!-- FIXME: stop octet count if tcp.pdu.size appears-->
    <xsl:when test="@name!='geninfo' "><!-- and count(preceding-sibling::*[name()='proto'])&lt;6-->
     <xsl:apply-templates> <!-- we expect to match "field" tags -->
         <xsl:with-param name="type">octet</xsl:with-param>
         </xsl:apply-templates>
    </xsl:when>
    
  </xsl:choose>

</xsl:template>

<!-- this matches the "packet" tag -->
<xsl:template match="packet">

  <!-- declare some variables for later use -->
  <xsl:variable name="frame_num" select="proto[@name='frame']/field[@name='frame.number']/@show"/>
  <xsl:variable name="frame_id"  select="concat($window,$frame_num)"/>
  <xsl:variable name="frame_c"   select="concat($frame_id,'c')"/>
  <!-- TODO after eternet proto make it general host src,dst -->
  <xsl:variable name="ip-src_host" select="proto[@name='ip']/field[@name='ip.src_host']/@show"/>
  <xsl:variable name="ip-dst_host" select="proto[@name='ip']/field[@name='ip.dst_host']/@show"/>
  <!-- TODO after ip proto make it general src,dst -->
  <xsl:variable name="tcp-srcport" select="proto[@name='tcp']/field[@name='tcp.srcport']/@show"/>
  <xsl:variable name="tcp-dstport" select="proto[@name='tcp']/field[@name='tcp.dstport']/@show"/>
  <xsl:variable name="count" select="count(ancestor::*)" />
  <xsl:variable name="lastProto" select="(proto)[last()]/@name" />
  
  <!-- the "title" bar of the frame -->
  <!--<div width="100%" id="{$frame_id}" >
  <table width="550px">
    <tr id="tr_{$frame_id}" style="background-color:#efefe1;" onClick="showFrame('{$window}','{$frame_id}', '{$frame_c}','span_octet_{$frame_c}')">
    <td width="100px">
    Frame <xsl:value-of select="$frame_num"/>:</td>
    
    <td width="200px"><xsl:value-of select="$ip-src_host"/> | <xsl:value-of select="$tcp-srcport"/></td>
    <td width="200px"><xsl:value-of select="$ip-dst_host"/> | <xsl:value-of select="$tcp-dstport"/></td>
    
    <td width="50px"><xsl:value-of select="$lastProto"/></td>
    
    </tr>
    </table>
  </div>
  -->
  <!-- the frame contents are stored in a div, so we can toggle it -->
  <div width="100%" id="{$frame_c}" style="display:none">
    <!-- loop trough all proto tags, but skip the "geninfo" one -->
    <span id="span_octet_{$frame_c}" style="display:none">
        <xsl:apply-templates/> <!-- we expect to match "proto" tags -->
         
        </span>
    <xsl:for-each select="proto[@name!='geninfo']">

      <xsl:variable name="proto" select="concat($frame_id,@name)"/>
      
      <!-- the "title" bar of the proto -->
      <!-- FIXME give proto num instead of proto name, since proto name can be identical -->
      <div width="100%" style="background-color:#e2e2e2; margin-bottom: 2px">
        <div width="100%" id="title_{$proto}">_<a href="javascript:toggle_node('{$proto}')">=></a>
        <span onClick="display('span_{$proto}','{$window}', 'title_{$proto}','span_octet_{$frame_c}','pos_{$proto}', 'size_{$proto}')">_<xsl:value-of select="@showname"/></span></div>
        <span id="span_{$proto}" style="display:none">
        <xsl:apply-templates> <!-- we expect to match "field" tags -->
         <xsl:with-param name="type">compair</xsl:with-param>
         </xsl:apply-templates>
        </span>
	
	<span id="pos_{$proto}" style="display:none"><xsl:value-of select="@pos"/></span>
	<span id="size_{$proto}" style="display:none"><xsl:value-of select="@size"/></span>
        <!-- print "proto" details inside another div -->
        <div width="100%" id="{$proto}" style="display:none" >
         <xsl:apply-templates> <!-- we expect to match "field" tags -->
         <xsl:with-param name="type">detail</xsl:with-param>
         </xsl:apply-templates>
        </div>
      </div>
    </xsl:for-each>
  </div>

  <!-- use the javascript function set_node_color() to set the color
       of the frame title bar. Defer colorization until the full page has
       been loaded. If the browser would support the XPath function
       replace() we could simply set the class attribute of the title bar div,
       but for now we're stuck with class names from Wireshark's colorfilters
       that contain spaces and we can't handle them in CSS. -->
  <script type="text/javascript">
    dojo.addOnLoad(function(){
      set_node_color(
        '<xsl:value-of select="$frame_id"/>',
        '<xsl:value-of select="proto[@name='frame']/field[@name='frame.coloring_rule.name']/@show"/>'
      );
    });
  </script>
</xsl:template>

<xsl:template match="pdml">
<script type="text/javascript">
	this.left = "";
	this.right = "";
	this.leftFrame = "";
	this.rightFrame = "";
	this.leftField = "";
	this.rightField = "";
	this.rightFrameContentId = "";
	this.leftFrameContentId = "";
    this.connArray = new Array();
    this.unknownArray = new Array();
  </script>
  Capture Filename: <b><xsl:value-of select="@capture_file"/></b>
  PDML created: <b><xsl:value-of select="@time"/></b>
  <!--<div width="100%" style="height: 400px; overflow-y: scroll;">
  <tt>-->
    <xsl:apply-templates/> <!-- we expect to match the "packet" nodes -->
  <!--</tt>
  </div>-->
  
</xsl:template>

<!-- this block matches the start of the PDML file -->
<xsl:template match="/">

<!--    <script src="raphael-min.js"></script>
<script src="underscore-min.js"></script>
<script src="sequence-diagram-min.js"></script>

<script src="raphael-min.js"></script>
<script src="diagram.js"></script>
<script src="jquery-plugin.js"></script>-->
<script src="jquery-1.9.1.min.js"></script>
    <script src="dojo_1_4.js" type="text/javascript"></script>
    <script type="text/javascript">


function showFrame(window, frameId, contentId, octetId) {
if(window === "right") {
	if(this.rightFrame === "") {
	
	} else {
	document.getElementById('tr_'+this.rightFrame).style.backgroundColor="#efefe1";
	document.getElementById(this.rightFrameContentId).innerHTML  = document.getElementById("frames2").innerHTML;
	
	}
	this.rightFrame = frameId;
	this.rightFrameContentId = contentId;
	document.getElementById('tr_'+frameId).style.backgroundColor="#b0e0e6";
	document.getElementById("frames2").innerHTML = document.getElementById(contentId).innerHTML;
	document.getElementById("octets2").innerHTML = document.getElementById(octetId).innerHTML;
	
} else {
if(this.leftFrame === "") {
	
	} else {
		document.getElementById('tr_'+this.leftFrame).style.backgroundColor="#efefe1";
	document.getElementById(this.leftFrameContentId).innerHTML  = document.getElementById("frames1").innerHTML;	
	}
	this.leftFrame = frameId;
	this.leftFrameContentId = contentId;
	document.getElementById('tr_'+frameId).style.backgroundColor="#b0e0e6";
	document.getElementById("frames1").innerHTML = document.getElementById(contentId).innerHTML;
	document.getElementById("octets1").innerHTML = document.getElementById(octetId).innerHTML;

}
document.getElementById(contentId).innerHTML = "";
}

function display(id, window, protoId, octetId,pos, size) {


if(window === "right") {
	if(this.right === "") {
	this.right = protoId;
	} else {
		document.getElementById(this.right).style.backgroundColor="#e2e2e2";
	this.right = protoId;	
	}
	document.getElementById(protoId).style.backgroundColor="#ffe6e6";
	document.getElementById("text1").innerHTML = document.getElementById(id).innerHTML;
	if(this.rightField != "") {
	document.getElementById(this.rightField).style.backgroundColor="#e2e2e2";
	this.rightField = "";
	}
	show_octet(window, octetId,pos, size);
} else {
	if(this.left === "") {
	this.left = protoId;
	} else {
		document.getElementById(this.left).style.backgroundColor="#e2e2e2";
	this.left = protoId;
	}
	document.getElementById(protoId).style.backgroundColor="#e6ffe6";
	document.getElementById("text2").innerHTML = document.getElementById(id).innerHTML;
	if(this.leftField != "") {
	
	document.getElementById(this.leftField).style.backgroundColor="#e2e2e2";
	this.leftField = "";
	}
	show_octet(window, octetId,pos, size);
}
 
}

function select_field(windowId, fieldId,octetId, posId, sizeId) {

if(windowId === "right") {
	if(this.rightField === "") {
	
	} else {
	document.getElementById(this.rightField).style.backgroundColor="#e2e2e2";
	
	
	}
	
	this.rightField = fieldId;
	document.getElementById(this.rightField).style.backgroundColor="#b0e0e6";
	
} else {
if(this.leftField === "") {
	
	} else {
		document.getElementById(this.leftField).style.backgroundColor="#e2e2e2";	
	}
	this.leftField = fieldId;
	document.getElementById(this.leftField).style.backgroundColor="#b0e0e6";
	

}
show_octet(windowId, octetId, posId, sizeId);

}

function show_octet(windowId, octetId, posId, sizeId) {

var pos = document.getElementById(posId).innerHTML;
var size = document.getElementById(sizeId).innerHTML;

var pos_int = pos / 1;
var size_int = size / 1;
var summa = pos_int + size_int;
var octet_outputId = "";

if(windowId === "right") {
  octet_outputId = "octets2";

} else {
	octet_outputId = "octets1";
}

var temp = document.getElementById(octetId).innerHTML;
temp = temp.replace(/\W/g,'');
var begin = temp.substr(0, pos_int*2);
var middle = temp.substr(pos_int*2, size_int*2);
var end = temp.substr(summa*2, temp.length-(summa*2));
//var end = 'end';
var output = "";

//document.getElementById(octet_outputId).innerHTML ="pos: "+ pos+' size: '+size+' pos+size: '+summa+' length: '+temp.length +' string: '+begin+'<span style="background-color:#e2e2e2; ">'+middle+'</span>'+end;
//document.getElementById(octet_outputId).innerHTML = temp;
<![CDATA[
for (var i=0; i < temp.length; i++) {

if(i === pos_int*2) {
 output = output + '<span style="background-color:#e2e2e2; ">';
}

if(i === pos_int*2+size_int*2) {
 output = output + '</span>';
}

if(i % 2 === 0) {
 output = output + '  ';
}

if(i % 16 === 0) {
 output = output + '  ';
}

if(i % 32 === 0) {
 output = output + '<br/>';
}

output = output+temp[i];
}
]]>
document.getElementById(octet_outputId).innerHTML = output;
}


function set_node(node, str)
{
	console.log("set_node");
  if(dojo.isString(node))
    node = dojo.byId(node);
  if(!node) return;
  node.style.display = str;
}
function toggle_node(node)
{
  if(dojo.isString(node)) {
  console.log("node_string");
    node = dojo.byId(node);
  } else {
  console.log("node_not_string");
  }
  if(!node)  {
  console.log("faszom");
  return;
  } else {
  set_node(node, (node.style.display != 'none') ? 'none' : 'block');
  }
}
function hide_node(node)
{
  set_node(node, 'none');
}
// this function was generated by colorfilters2js.pl
function set_node_color(node,colorname)
{
  if(dojo.isString(node))
    node = dojo.byId(node);
  if(!node) return;
  var fg='';
  var bg='';
  
  if(colorname == 'Bad TCP') {
    bg='#000000';
    fg='#ff5f5f';
  }
  if(colorname == 'HSRP State Change') {
    bg='#000000';
    fg='#fff600';
  }
  if(colorname == 'Spanning Tree Topology  Change') {
    bg='#000000';
    fg='#fff600';
  }
  if(colorname == 'OSPF State Change') {
    bg='#000000';
    fg='#fff600';
  }
  if(colorname == 'ICMP errors') {
    bg='#000000';
    fg='#00ff0e';
  }
  if(colorname == 'ARP') {
    bg='#d6e8ff';
    fg='#000000';
  }
  if(colorname == 'ICMP') {
    bg='#c2c2ff';
    fg='#000000';
  }
  if(colorname == 'TCP RST') {
    bg='#900000';
    fg='#fff680';
  }
  if(colorname == 'TTL low or unexpected') {
    bg='#900000';
    fg='#ffffff';
  }
  if(colorname == 'Checksum Errors') {
    bg='#000000';
    fg='#ff5f5f';
  }
  if(colorname == 'SMB') {
    bg='#fffa99';
    fg='#000000';
  }
  if(colorname == 'HTTP') {
    bg='#8dff7f';
    fg='#000000';
  }
  if(colorname == 'IPX') {
    bg='#ffe3e5';
    fg='#000000';
  }
  if(colorname == 'DCERPC') {
    bg='#c797ff';
    fg='#000000';
  }
  if(colorname == 'Routing') {
    bg='#fff3d6';
    fg='#000000';
  }
  if(colorname == 'TCP SYN/FIN') {
    bg='#a0a0a0';
    fg='#000000';
  }
  if(colorname == 'TCP') {
    bg='#e7e6ff';
    fg='#000000';
  }
  if(colorname == 'UDP') {
    bg='#70e0ff';
    fg='#000000';
  }
  if(colorname == 'Broadcast') {
    bg='#ffffff';
    fg='#808080';
  }
  if(fg.length > 0)
    node.style.color = fg;
  if(bg.length > 0)
    node.style.background = bg;
    
}
    </script>
  
    <!-- 
    <textarea id="language" rows="10" cols="50" style="visibility: hidden; height: 10px;">
    </textarea>
    <br/>
    <button id="parse" type="button">Display</button><br/>
    <div class="diagram"></div>  TODO: diagram feature should be removed from xsl completly--> 
    unknown protocol on these links:<br/>
    <div id="{$window}unknown"></div>
      <xsl:apply-templates/> <!-- we expect to match the "pdml" node -->
      
      <!--<script>
      
      $(document).ready(function(){
      
       $(".diagram").sequenceDiagram({theme: 'simple'});
                $('#parse').click(_.throttle( function() {
                	$('.diagram').text($('#language').val());
                    //this.diagram = Diagram.parse($('#language').val());
                    console.log('.diagram');
                    $(".diagram").sequenceDiagram({theme: 'simple'});
                    //this.diagram.drawSVG('diagram', {theme: 'hand'});

                

                }, 100));
            });
 
      </script>-->
   
</xsl:template>

</xsl:stylesheet>
